home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tech91.zip / TI698.ASC < prev    next >
Text File  |  1991-08-26  |  6KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox                                NUMBER  :  698
  9.   VERSION  :  3.5
  10.        OS  :  DOS
  11.      DATE  :  August 26, 1991                          PAGE  :  1/3
  12.  
  13.     TITLE  :  Conditional Fields in Forms and Reports in Paradox
  14.  
  15.  
  16.  
  17.  
  18.   While the Paradox report generator when combined with queries has
  19.   great flexibility and power, frequently the ability to do IF -
  20.   THEN conditions in reports is desired.  To a limited degree the
  21.   addition of logic to the report generator can be achieved through
  22.   skillful use of some of the PAL functions: search(), substr() and
  23.   len().
  24.  
  25.   With all the variations of the below listed formula which are
  26.   possible, the key to achieving the desired result stems from
  27.   thoroughly understanding the search and substring  functions.
  28.  
  29.   NOTE: Knowledge of PAL is a prerequisite for attempting the ideas
  30.   contained in this document.
  31.  
  32.        Search - returns the position of one string within another
  33.  
  34.           syntax:  Search(substring,string)
  35.                     where substring is an expression containing
  36.                     the substring you want to locate within
  37.                     String.
  38.  
  39.        examples:  Search("in","mine")                = 2
  40.                      Search("ni","mine")             = 0
  41.                      Search("in","mining")           = 2
  42.                      (first occurrence)
  43.  
  44.                      Search(1,123456)                = 1
  45.                      Search([fieldname],[fieldname]) = 1
  46.  
  47.        Substr - returns a subset or 'subtring' of a string
  48.  
  49.        syntax:  Substr("String",x,y)
  50.                      where x=position of character to start at in
  51.                      String and y=total number of characters to
  52.                      extract.
  53.  
  54.        examples:  Substr("cat",2,2)                  = at
  55.                      Substr("cat",0,2)               = blank
  56.                      Substr("cat",2,0)               = blank
  57.                      Substr("cat",1,255)             = cat
  58.  
  59.   Note that a "0" in either column of this function returns a
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox                                NUMBER  :  698
  75.   VERSION  :  3.5
  76.        OS  :  DOS
  77.      DATE  :  August 26, 1991                          PAGE  :  2/3
  78.  
  79.     TITLE  :  Conditional Fields in Forms and Reports in Paradox
  80.  
  81.  
  82.  
  83.  
  84.   blank.  By setting the Search function (which can be set to
  85.   return a "0" or "1") equal to x in the substr function, one can
  86.   make the display of "String" conditional.
  87.  
  88.        Len - returns the length of a string
  89.  
  90.        syntax:  Len("String")
  91.  
  92.        examples: Len("String")                       = 6
  93.                  Len("cat")                          = 3
  94.  
  95.  
  96.   Example 1:
  97.  
  98.   Substr("Text",search([fieldname]),a),255
  99.         or more specifically,
  100.  
  101.   Substr("Dangerous Level",search([level],5),255)
  102.  
  103.   If the value for the field [level] in that record was
  104.   equal to 5, then the Search function would equate to 1, thus
  105.   displaying or printing the message "Dangerous Level".  If [level]
  106.   is 0, then the text will not be printed.
  107.  
  108.   Example 2: Multi-conditional formula
  109.  
  110.   Substr("Dangerous Level",search([level],5),255) +
  111.   Substr("Safe Level",search([level],1),255)
  112.  
  113.   This is simply example 1 concatenated with another substr
  114.   formula checking against a value of 1.  Thus if [level]=5 then
  115.   "Dangerous Level"+blank yields "Dangerous Level".  If [level]=5
  116.   then blank+"Safe Level" = "Safe Level".  All other values of
  117.   [level] will result in no text being printed in a report or
  118.   displayed in a form.
  119.  
  120.   Example 3: Multi-conditional formula using the Len function
  121.  
  122.   Occasionally it may be desirable to print reports with labels
  123.   where one of the fields may be empty.  Normally in Paradox this
  124.   can result in an extra space being printed.  For example if the
  125.   data includes a salutation field which may in some cases be
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox                                NUMBER  :  698
  141.   VERSION  :  3.5
  142.        OS  :  DOS
  143.      DATE  :  August 26, 1991                          PAGE  :  3/3
  144.  
  145.     TITLE  :  Conditional Fields in Forms and Reports in Paradox
  146.  
  147.  
  148.  
  149.  
  150.   empty, the report will output a blank space even if field squeeze
  151.   is used; and a calculated field [Sal] + " " + [F] + " " + [L]
  152.   will not correct this.  Unfortunately this is a scenario that
  153.   neither fieldsqeeze nor a calculated field can adequately handle.
  154.  
  155.   The example below will remove the extra space encountered when
  156.   the salutation field is empty, use the following expression in a
  157.   calculated field.
  158.  
  159.    substr([Sal]+" "+[F]+" "+[L],1-search(len([Sal]),0),255)+
  160.    substr([Sal]+[F]+" "+[L],search(len([Sal]),0),255)
  161.  
  162.   The entire expression must be typed on a single line.
  163.  
  164.   The string [Sal] represents the salutation field,
  165.              [F]   represents the First name field, and
  166.              [L]   represents the last name field.
  167.  
  168.   Substitute in your field names.
  169.  
  170.   These formulas can be placed in calculated fields in both
  171.   reports and forms.  The limitations here are that the expressions
  172.   can only be 175 characters in length.  There is a wide variety of
  173.   combinations possible with the substr function given that there
  174.   are three components to the expression that can be manipulated.
  175.   Whenever this is explored, be sure to test for all possible
  176.   values as it is very easy to come across limitations and
  177.   unexpected results.
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.